package com.itheima.filter;

import javax.servlet.*;
import java.io.IOException;

// 创建一个过滤器类
//@WebFilter(urlPatterns = "/*")  // /*表示拦截所有请求
public class XyzFilter implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//        System.out.println("init初始化方法执行了");
//    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("XyzFilter拦截到了请求");
        System.out.println("XyzFilter执行放行前的逻辑");
        // 放行
        filterChain.doFilter(servletRequest, servletResponse);

        System.out.println("XyzFilter执行放行后的逻辑");
    }

//    @Override
//    public void destroy() {
//        System.out.println("destroy销毁方法执行了");
//    }
}
